/*
 * 
 */
package lik.http.videoplay.action;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import lik.http.videoplay.service.MediaFileService;

/**
 * 
 * 
 * @author <A HREF="mailto:li_kan@vobile.cn">Licey</A> 2012-2-24
 * 
 */
public class VideoIndexServlet extends HttpServlet {

	private static final long serialVersionUID = -7543409939702809707L;
	private MediaFileService mediaFileService;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setAttribute("files", mediaFileService.getMedias());
		getServletContext().getRequestDispatcher("/index.jsp").forward(req, resp);
	}

	@Override
	public void init(ServletConfig config) throws ServletException {
		mediaFileService = MediaFileService.initMediaFileService(config.getInitParameter("path"));
		super.init(config);
	}
}
